package com.zhenmyan.secdeal.vo;

import com.zhenmyan.secdeal.Enum.ResponseEnum;
import lombok.Data;

/**
 * description:
 *
 * @author 颜真明
 * @date 2023/5/5  15:16
 */
@Data
public class Response {

    private int code;
    private String message;
    private Object obj;

    Response() {}

    Response(int code, String message, Object obj) {
        this.code = code;
        this.message = message;
        this.obj = obj;
    }

    public static Response error(ResponseEnum responseEnum) {
        return new Response(responseEnum.getCode(), responseEnum.getMessage(), null);
    }

    public static Response error(Object o) {
        return new Response(ResponseEnum.ERROR.getCode(), ResponseEnum.ERROR.getMessage(), o);
    }

    public static Response success(ResponseEnum responseEnum) {
        return new Response(responseEnum.getCode(), responseEnum.getMessage(), null);
    }

    public static Response success(Object o) {
        return new Response(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMessage(), o);
    }

}
